  // NoteTag.swift

import Vapor
import Fluent

final class NoteTag: Model, Content, @unchecked Sendable {
  static var schema: String { SchemaEnum.noteTags.rawValue }
  
  @ID(key: .id)
  var id: UUID?
  
  @Field(key: FieldKeys.name)
  var name: String
  
  @Parent(key: FieldKeys.user)
  var user: User
  
  @Timestamp(key: FieldKeys.createdAt, on: .create)
  var createdAt: Date?
  
  @Timestamp(key: FieldKeys.updatedAt, on: .update)
  var updatedAt: Date?
  
  init() { }
  
  init(id: UUID? = nil, name: String, userID: User.IDValue) {
    self.id = id
    self.name = name
    self.$user.id = userID
  }
  
    // 创建标签请求
  struct Create: Content {
    let name: String
  }
  
    // 更新标签请求
  struct Update: Content {
    let name: String
  }
  
    // 标签响应
  struct Response: Content {
    let id: UUID?
    let name: String
    let userID: UUID
    let createdAt: Date?
    let updatedAt: Date?
    let noteCount: Int?
  }
  
    // 删除标签请求
  struct Delete: Content {
    let deleteNotes: Bool  // 是否同时删除标签下的笔记
  }
}
